/**
 * @Author: lifuzhao
 * @Date: 2019-07-11
 * @Project: driver
 */
import axios from '../plugins/axios'

let getCouponListSuccess = false
export default {
  async getCouponList(context, options) {
    if (options.forceRefresh !== false || !getCouponListSuccess) {
      return axios.get('/api/v1/tickets/manage', {
        params: options.params
        , abort: options.abort
      })
        .then(res => {
          let {data = [], success} = res
          getCouponListSuccess = success
          context.commit('setCouponList', data)
          return res
        })
        .catch(res => {
          context.commit('setCouponList', [])
          return res
        })
    }
  }
}